package com.zlc.platform.controller;

import com.zlc.common.common.entity.PageVo;
import com.zlc.common.core.user.model.vo.MayanPlatUserAgentVo;
import com.zlc.common.model.base.IdReq;
import com.zlc.common.model.user.UserAgentRequest;
import com.zlc.platform.service.UserAgentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户代理相关接口
 */
@Api(tags = "代理用户相关")
@RestController
@Slf4j
@RequestMapping("/api/user/agent")
public class UserAgentController {

    @Autowired
    private UserAgentService userAgentService;

    /**
     * 查询代理用户
     */
    @ApiOperation(value = "查询代理用户")
    @PostMapping(value = "/queryAgentList")
    public PageVo<MayanPlatUserAgentVo> queryAgentList(@RequestBody UserAgentRequest request) {
        return userAgentService.queryAgentList(request);
    }

    /**
     * 添加代理用户
     */
    @ApiOperation(value = "添加代理用户")
    @PostMapping(value = "/addAgent")
    public void addAgent(@RequestBody MayanPlatUserAgentVo agentVo) {
        userAgentService.addAgent(agentVo);
    }

    /**
     * 更新代理用户
     */
    @ApiOperation(value = "更新代理用户")
    @PostMapping(value = "/updateAgent")
    public void updateAgent(@RequestBody MayanPlatUserAgentVo agentVo) {
        userAgentService.updateAgent(agentVo);
    }

    /**
     * 删除代理用户
     */
    @ApiOperation(value = "删除代理用户")
    @PostMapping(value = "/removeAgent")
    public void removeAgent(@RequestBody IdReq req) {
        userAgentService.removeAgent(req.getId());
    }
}
